package com.app.demoo3.conntroller;
import com.app.demoo3.entity.Invitation;
import com.app.demoo3.service.InvitationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Controller
public class HomeController {
    @Autowired
    private InvitationService invitationService;

    @RequestMapping("/show")
    public String index(@RequestParam(value = "title",defaultValue = "") String title, Model model){
        List<Invitation> userList = invitationService.getUserList(title);
        model.addAttribute("userList",userList);
        model.addAttribute("title",title);
        return "index";
    }
}
